﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="tegevusalaType_v4", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(TegevusalaTypeV4))]
    public class TegevusalaTypeV4Serializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected ITegevusalaTypeV4 clazz;
        
        public TegevusalaTypeV4Serializer(ITegevusalaTypeV4 clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.EmtakKood!=null) {
                Writer.WriteStartElement("emtak_kood");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.EmtakKood))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Versioon!=null) {
                Writer.WriteStartElement("versioon");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.Versioon))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Nimetus!=null) {
                Writer.WriteStartElement("nimetus");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Nimetus))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
        START:
            if ((Reader.LocalName == "emtak_kood")) {
                goto emtak_kood;
            }
            else {
                if ((Reader.LocalName == "versioon")) {
                    goto versioon;
                }
                else {
                    if ((Reader.LocalName == "nimetus")) {
                        goto nimetus;
                    }
                    else {
                        return;
                    }
                }
            }
        emtak_kood:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>tegevusalaType_v4>emtak_kood");
            }
            clazz.EmtakKood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("emtak_kood")).Value;
            goto START;
        versioon:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>tegevusalaType_v4>versioon");
            }
            clazz.Versioon = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("versioon")).Value;
            goto START;
        nimetus:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>tegevusalaType_v4>nimetus");
            }
            clazz.Nimetus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("nimetus")).Value;
            goto START;
        }
    }
}
